﻿@using ECGadmin.WebUI.CustomHelpers
@using ECGadmin.WebUI.Models
@model IEnumerable<ECGadmin.Common.ViewCateTemplatePagingDto>
@{
    ViewBag.Title = "Template danh mục";
    Layout = "~/Views/Shared/_layout.cshtml";
}
@section LeftMenu
{
    <div id="left">
        <div class="LeftMenuWraper">
            <div class="leftMenuHeader">
                <span style="padding-left: 10px;">
                    <strong>Truy cập nhanh</strong>
                </span>
            </div>
            <ul id="p-quick-menu" class="quick-menu">
                <li class="qmn-info-pro">
                    <a href="@Url.Action("Index", "ProductCategory")">Thông tin danh mục</a>
                </li>
                <li class="qmn-info-pro">
                    <a href="@Url.Action("CategoryBanner", "ProductCategory")">Banners category</a>
                </li>
                <li class="qmn-info-pro">
                    <a href="@Url.Action("TemplateList", "ProductCategory")">Template danh mục</a>
                </li>
                <li class="qmn-info-pro">
                    <a href="@Url.Action("Index", "ProductCategoryMapLink")">Liên kết danh mục</a>
                </li>
            </ul>
            <div class="leftMenuFooter"></div>
        </div>
    </div>
    <!-- END #left -->
}
<nav>
    <div id="jCrumbs" class="breadCrumb module">
        <ul>
            <li><a href="@Url.Action("Index","Home")"><i class="bootstrap icon-home"></i></a></li>
            <li><a href="javascript:void(0)">Temlate danh mục</a> </li>
        </ul>
    </div>
</nav>

<div class="toolBox">
    @Html.ToolBox(new List<object> { new Add { ClassCss = "Add", ActionName = "/ProductCategory/AddTemplateCategory" } })
</div>
<div class="box-Info">
    <div class="Info-header">
        <span>Template theo danh mục</span>
    </div>
    <div class="Info-body" style="overflow:hidden;">
        <table class="table-odd table-plist">
            <colgroup>
                <col style="width: 30px" />
                <col />
                <col style="width: 70px" />
            </colgroup>
            <tr>
                <th scope="col">STT</th>
                <th scope="col">Mô tả</th>
                <th scope="col"></th>
            </tr>
            @foreach (var item in Model)
    {
        <tr class="@string.Format("bn-{0}", item.Id)">
            <td>@item.STT</td>
            <td>
                @item.Description
            </td>
            <td>
                <a href="@Url.Action("EditTemplateCategory", "ProductCategory", new { id = item.Id })" title="chỉnh sửa" class="icon-edit-v2 fl-l bootstrapTangoSmall"></a>
                @Ajax.ActionLink("Xóa", "DeleteTemplateCategory", "ProductCategory", new { id = item.Id }, new AjaxOptions
                                                                                                 {
                                                                                                     Confirm = "Bạn chắc chắn muốn xóa Template này!",
                                                                                                     OnSuccess = "AjaxReturnDataDeleteTemplate"
                                                                                                 }, new { @class = "icon-delete fl-l bootstrapTangoSmall", title = "xóa" })
            </td>
        </tr>
    }
        </table>

        <div class="p-paging">
            @Html.PageLinks((PageInfo)ViewBag.PageInfo, i => Url.Action("TemplateList", "ProductCategory", new { page = i }))
        </div>
    </div>
</div>
@section scripts
{
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script type="text/javascript">
        //------- Ajax kết quả trả về khi xóa chiết khấu ----------------
        function AjaxReturnDataDeleteTemplate(data) {
            if (data) {
                window.location = document.URL;
            } else {
                alert("Template này đã có danh mục sử dụng!");
            }
        }
    </script>
}

